﻿Public Class Form1

    'Interaction

    Private Sub Sow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sow.Click
        If Grass.Text >= 25 Then
            MsgBox("The field is not sowed yet")
        Else
            Timer1.Enabled = True
            Eat.Enabled = False
            Sow.Enabled = False
        End If

    End Sub

    Private Sub Draw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Draw.Click
        If Water.Text >= 30 Then
            MsgBox("The well is not pumped yet")
        Else
            Timer2.Enabled = True
            Drink.Enabled = False
            Draw.Enabled = False
        End If
    End Sub

    Private Sub Eat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Eat.Click
        Domba1.Eat()
    End Sub

    Private Sub Drink_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Drink.Click
        Domba1.Drink()
    End Sub

    'Elemen
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Grass.Text < 100 Then
            Grass.Text += 1
        Else
            Timer1.Enabled = False
            Eat.Enabled = True
            Sow.Enabled = True
        End If
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        If Water.Text < 100 Then
            Water.Text += 1
        Else
            Timer2.Enabled = False
            Drink.Enabled = True
            Draw.Enabled = True
        End If
    End Sub

    'Additional

    Public Sub Redo()
        Done()
        Sow.Enabled = True
        Draw.Enabled = True
        Domba1.vStat = 0
        Domba1.Grow()
        Grass.Text = 100
        Water.Text = 100
        GW.Text = 0
        WW.Text = 0
        C1.Text = 0
        C2.Text = 0
        C3.Text = 0
        Pts.Text = 0
    End Sub

    Public Sub Done()
        Domba1.Timer1.Enabled = False
        Domba1.Timer2.Enabled = False
        Domba1.Timer3.Enabled = False
        Domba1.Timer4.Enabled = False
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If GW.Text >= 1 And WW.Text >= 0 Then
            GW.Text -= 1
            C1.Text += 1
            Pts.Text += 100
        Else
            MsgBox("Not enough materials")
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If GW.Text >= 2 And WW.Text >= 1 Then
            GW.Text -= 2
            WW.Text -= 1
            C2.Text += 1
            Pts.Text += 250
        Else
            MsgBox("Not enough materials")
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If GW.Text >= 0 And WW.Text >= 2 Then
            WW.Text -= 2
            C3.Text += 1
            Pts.Text += 400
        Else
            MsgBox("Not enough materials")
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Out.Click
        MessageBox.Show("Your Score : " & Me.Pts.Text, "Result")
        Close()
    End Sub
End Class
